package Text_40;

import java.util.ArrayList;
import java.util.Scanner;

public class Code {

	public static void main(String[] args) {
		 //整数各位积和之差
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个整数：");
        int num1 = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        getNumber(list,num1);
        System.out.println("sum = "+getSum(list));
        System.out.println("amass = "+getAmass(list));
        if(num1==1){
            System.out.println(0);;
        }else{
                System.out.println("amass-sum = "+(getAmass(list) - getSum(list)));
//            }else if(getAmass(list)< getSum(list)){
//                System.out.println( getSum(list)-getAmass(list) );
//            }
        }

//
//            System.out.println("amass-sum = "+(getAmass(list)-getSum(list)));
//        for (int i = 0; i < list.size(); i++) {
//            System.out.println(list.get(i)+" ");
//        }
    }
    public static void  getNumber(ArrayList<Integer> list,int num1){
        int num2 = num1;
        while(num2>=1){
            int ge = num2%10;
            num2 = num2/10;
            list.add(ge);
        }
    }
    public static int getSum(ArrayList<Integer> list){
        int sum = 0;
        for (int i = 0; i < list.size(); i++) {
          sum = sum + list.get(i);
        }
        return sum;
    }
    public static int getAmass(ArrayList<Integer> list){
        int amass = 1;
        for (int i = 0; i < list.size(); i++) {
            amass = amass * list.get(i);
        }
        return amass;

	}

}
